{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "rental-portal",
   "metadata": {},
   "source": [
    "# Europe Health"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "removed-banner",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import matplotlib.pyplot as plt\n",
    "import numpy as np\n",
    "import seaborn as sns\n",
    "import plotly.express as px\n",
    "import plotly.graph_objects as go\n",
    "from plotly.subplots import make_subplots\n",
    "import plotly.figure_factory as ff\n",
    "import os, shutil"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "novel-investment",
   "metadata": {},
   "source": [
    "## Open Questions"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "applicable-brunswick",
   "metadata": {},
   "source": [
    "* Data Source\n",
    "* Data current date"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ruled-symphony",
   "metadata": {},
   "source": [
    "### Importing the data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "weekly-saver",
   "metadata": {},
   "outputs": [],
   "source": [
    "#description of the respective features\n",
    "pd.set_option('display.max_colwidth', None)\n",
    "desc_df = pd.read_csv('Supply_Food_Data_Descriptions.csv', index_col = 'Categories')\n",
    "desc_df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "future-duncan",
   "metadata": {},
   "outputs": [],
   "source": [
    "# change the directory to the one of your \"food\" folder here\n",
    "files = os.listdir('/Users/franz/Desktop/DV Project/Dashboard/diet_corona/food/')\n",
    "if '.DS_Store' in files:\n",
    "    files.remove('.DS_Store')\n",
    "directory = '/Users/franz/Desktop/DV Project/Dashboard/diet_corona/food/' + files[0]\n",
    "\n",
    "this_df = pd.read_csv(directory)[[\"Area\", \"Item\", \"Value\"]].set_index(\"Area\", drop=True)\n",
    "name = this_df.iloc[0,0]\n",
    "this_df = this_df.rename(columns={\"Value\":name}).drop(columns=\"Item\")\n",
    "food_supply = this_df\n",
    "\n",
    "for i in range(1,len(files)):\n",
    "    directory = '/Users/franz/Desktop/DV Project/Dashboard/diet_corona/food/' + files[i]\n",
    "    this_df = pd.read_csv(directory)[[\"Area\", \"Item\", \"Value\"]].set_index(\"Area\", drop=True)\n",
    "    name = this_df.iloc[0,0]\n",
    "    this_df = this_df.rename(columns={\"Value\":name}).drop(columns=\"Item\")\n",
    "    food_supply = pd.concat([food_supply, this_df], axis=1)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "actual-intensity",
   "metadata": {},
   "outputs": [],
   "source": [
    "smo = pd.read_csv(\"share-of-adults-who-smoke.csv\")\n",
    "#retrieved from https://ourworldindata.org/smoking\n",
    "smo = smo[smo[\"Year\"] == 2016].rename(columns={\"Code\":\"iso_a3\", \"Smoking prevalence, total (ages 15+)\":\"Smoking\"})\n",
    "smo = smo[[\"Entity\", \"Smoking\"]].set_index(\"Entity\", drop = True)\n",
    "food_supply = pd.concat([food_supply, smo], axis = 1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "healthy-morocco",
   "metadata": {},
   "outputs": [],
   "source": [
    "smo[\"Smoking\"].std()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "direct-organ",
   "metadata": {},
   "outputs": [],
   "source": [
    "obes = pd.read_csv('Food_Supply_Quantity_kg_Data.csv')[[\"Country\", \"Obesity\"]].set_index(\"Country\")\n",
    "food_supply = pd.concat([food_supply, obes], axis = 1)\n",
    "food_supply = food_supply.reset_index().rename(columns={\"index\":\"Country\"})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "little-billion",
   "metadata": {},
   "outputs": [],
   "source": [
    "exp = pd.read_excel(\"h_exp.xlsx\")\n",
    "#https://ec.europa.eu/eurostat/databrowser/view/HLTH_SHA11_HF__custom_227597/bookmark/table?lang=en&bookmarkId=1530a1e6-767e-4661-9e15-0ed2f7fae0d5\n",
    "\n",
    "exp.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "global-perception",
   "metadata": {},
   "source": [
    "### Data Preprocessing"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "twelve-pulse",
   "metadata": {},
   "outputs": [],
   "source": [
    "#keep only countries from the EU\n",
    "eu_countries_list = [\"Austria\",\"Belgium\",\"Bulgaria\",\"Croatia\",\"Cyprus\",\"Czechia\",\"Denmark\",\"Estonia\",\"Finland\",\"France\",\n",
    "                    \"Germany\",\"Greece\",\"Hungary\",\"Ireland\",\"Italy\",\"Latvia\",\"Lithuania\",\"Luxembourg\",\"Malta\",\"Netherlands\",\"Poland\",\n",
    "                    \"Portugal\",\"Romania\",\"Slovakia\",\"Slovenia\",\"Spain\",\"Sweden\"]\n",
    "\n",
    "food_supply = food_supply[food_supply[\"Country\"].isin(eu_countries_list)]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "beneficial-martial",
   "metadata": {},
   "outputs": [],
   "source": [
    "def cz(s):\n",
    "    if s == \"Czech Republic\":\n",
    "        return \"Czechia\"\n",
    "    elif s == \"Slovak Republic\":\n",
    "        return \"Slovakia\"\n",
    "    else:\n",
    "        return s\n",
    "\n",
    "exp[\"Country Name\"] = exp[\"Country Name\"].apply(cz)\n",
    "exp = exp[exp[\"Country Name\"].isin(eu_countries_list)]\n",
    "\n",
    "len(exp)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "demographic-differential",
   "metadata": {
    "scrolled": false
   },
   "outputs": [],
   "source": [
    "#check for nan values\n",
    "if food_supply.dropna().shape == food_supply.shape:\n",
    "    print(\"There are no nan values!\")\n",
    "else:\n",
    "    print(food_supply.isna().sum())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "infectious-perspective",
   "metadata": {},
   "outputs": [],
   "source": [
    "#drop columns with nans\n",
    "food_supply = food_supply.drop(columns=[\"Sugar Crops\", \"Miscellaneous\"])"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "worst-seattle",
   "metadata": {},
   "source": [
    "### Assessing the variables"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "interstate-massage",
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "print(\"There are\", food_supply.shape[1], \"different columns in the food_supply DataFrame!\")\n",
    "food_supply.columns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "exposed-citizen",
   "metadata": {},
   "outputs": [],
   "source": [
    "food_supply.info()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "sunrise-angel",
   "metadata": {},
   "source": [
    "### Adding Covid-19 realted Data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "welcome-roads",
   "metadata": {},
   "outputs": [],
   "source": [
    "# cases, deaths, tests, vaccinations"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "smoking-excitement",
   "metadata": {},
   "outputs": [],
   "source": [
    "vacc = pd.read_csv(\"https://covid.ourworldindata.org/data/owid-covid-data.csv?v=2021-03-23\")\n",
    "vacc.columns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "protective-norman",
   "metadata": {},
   "outputs": [],
   "source": [
    "#retrieved from https://covid.ourworldindata.org/data/owid-covid-data.csv?v=2021-03-23\n",
    "vacc = vacc[vacc[\"date\"] == \"2021-03-20\"] \n",
    "vacc = vacc[vacc[\"location\"].isin(eu_countries_list)]\n",
    "vacc = vacc[[\"location\", \"total_cases_per_million\", \"total_deaths_per_million\", \"life_expectancy\", \"human_development_index\", \"population_density\", \"median_age\", \"gdp_per_capita\", \"cardiovasc_death_rate\", \"diabetes_prevalence\"]] # , \"total_tests_per_thousand\", \"total_vaccinations_per_hundred"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "olympic-outdoors",
   "metadata": {},
   "outputs": [],
   "source": [
    "food_supply = food_supply.set_index(\"Country\", drop=True)\n",
    "exp = exp.set_index(\"Country Name\", drop=True)\n",
    "vacc = vacc.set_index(\"location\", drop = True)\n",
    "food_supply = pd.concat([food_supply, vacc, exp], axis = 1)\n",
    "food_supply.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "visible-accent",
   "metadata": {},
   "outputs": [],
   "source": [
    "#check for nan values\n",
    "if food_supply.dropna().shape == food_supply.shape:\n",
    "    print(\"There are no nan values!\")\n",
    "else:\n",
    "    print(food_supply.isna().sum())"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "comic-queue",
   "metadata": {},
   "source": [
    "### Checking correlations"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "advanced-table",
   "metadata": {},
   "outputs": [],
   "source": [
    "def corr(df, color):\n",
    "    fig = plt.figure(figsize=(20,16))\n",
    "    mask = np.zeros_like(df.corr())\n",
    "    mask[np.triu_indices_from(mask)] = True\n",
    "    sns.heatmap(df.corr().round(2), annot=True, cmap=color, linewidths=0.2, mask=mask, vmin=-1, vmax=1)\n",
    "    plt.xticks(fontsize=11)\n",
    "    plt.yticks(fontsize=11)\n",
    "    plt.savefig(\"correlation.pdf\");"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "atlantic-amazon",
   "metadata": {},
   "outputs": [],
   "source": [
    "food_supply = food_supply.rename(columns = {\"life_expectancy\":\"Life Expectancy\", \"human_development_index\":\"Human Development Index\",\n",
    "                             \"population_density\":\"Population Density\", \"median_age\":\"Median Age\",\n",
    "                             \"gdp_per_capita\":\"GDP per Capita\", \"cardiovasc_death_rate\":\"Cardiovascular Death Rate\",\n",
    "                             \"diabetes_prevalence\":\"Diabetes Prevalence\"})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "clinical-prior",
   "metadata": {},
   "outputs": [],
   "source": [
    "corr(food_supply, \"plasma\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "smoking-dancing",
   "metadata": {},
   "source": [
    "### Feature engineering"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "radical-momentum",
   "metadata": {},
   "outputs": [],
   "source": [
    "food_supply[\"Country\"] = food_supply.index\n",
    "food_supply.to_csv(\"scatter_data.csv\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "written-rouge",
   "metadata": {},
   "source": [
    "# Part 1: Eating habits of the 27 EU countries - Map(s)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "solar-sheriff",
   "metadata": {},
   "source": [
    "This part contains the per country per capita per year food consumption of different kinds of foods in kilogram. This includes the following 19 food categories:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "stuffed-fault",
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "foods = food_supply.iloc[:,:20].columns.tolist()\n",
    "foods"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "demonstrated-packaging",
   "metadata": {},
   "source": [
    "# Part 2: Correlation of the food habits and general information about the country"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "municipal-generator",
   "metadata": {},
   "source": [
    "## Watch out for outliers!"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "russian-captain",
   "metadata": {},
   "source": [
    "This part investigates if there are any correlations between a countries eating habits and the general data about the country. This general data includes the following variables:\n",
    "* GDP per capita\n",
    "* Human Development Index\n",
    "* Population Density\n",
    "* Median Age"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "partial-confirmation",
   "metadata": {},
   "outputs": [],
   "source": [
    "def scatter_plot(df, x, y, size):\n",
    "    '''insert x and y as string while x entails color coding (abv avg...)'''\n",
    "    \n",
    "    # feature engineering\n",
    "    col_name = str(y) + \" above avg\"\n",
    "    food_supply[col_name] = (df[y] > df[y].mean()).astype(int)\n",
    "    \n",
    "    size = df[size] * 1/4\n",
    "    \n",
    "    # plotting\n",
    "    fig = px.scatter(df, x=x, y =y, size=size, color_continuous_scale=px.colors.sequential.Plasma, color=col_name,hover_name=df.index, log_x=False, trendline = \"ols\",  trendline_color_override=\"#bd3786\",marginal_x = \"box\",marginal_y = \"box\", template=\"simple_white\")\n",
    "    fig.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "obvious-collectible",
   "metadata": {},
   "outputs": [],
   "source": [
    "general_food_cor = food_supply.corr()[[\"GDP per Capita\", \"Human Development Index\", \"Median Age\", \"Population Density\"]].T[foods]\n",
    "fig = plt.figure(figsize=(20,5))\n",
    "sns.heatmap(general_food_cor.round(2), annot=True, cmap=\"plasma\", linewidths=0.2, vmin=-1, vmax=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "indirect-sister",
   "metadata": {},
   "outputs": [],
   "source": [
    "general_cor = food_supply[[\"GDP per Capita\", \"Human Development Index\", \"Median Age\", \"Population Density\"]].corr()\n",
    "general_cor"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "lasting-liverpool",
   "metadata": {},
   "outputs": [],
   "source": [
    "scatter_plot(food_supply , \"GDP per Capita\", \"Stimulants\", \"Human Development Index\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "reliable-assessment",
   "metadata": {},
   "source": [
    "# Part 3: Correlation of the food habits and health information about the country"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "collective-sense",
   "metadata": {},
   "source": [
    "This part investigates if there are any correlations between a countries eating habits and the health data about the country. This data includes the following variables:\n",
    "* Obesity\n",
    "* Life Expectancy\n",
    "* Cardiovasc Death Rate"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "olympic-vaccine",
   "metadata": {},
   "outputs": [],
   "source": [
    "health_food_cor = food_supply.corr()[[\"Obesity\", \"Diabetes Prevalence\", \"Cardiovascular Death Rate\", \"Life Expectancy\", \"Health Expenditure\" ]].T[foods].T\n",
    "fig = plt.figure(figsize=(10,10))\n",
    "sns.heatmap(health_food_cor.round(2), annot=True, cmap=\"plasma\", linewidths=0.2, vmin=-1, vmax=1)#.set_yticklabels([\"Obesity\", \"Diabetes Prevalence\", \"Cardiovascular Death Rate\", \"Life Expectancy\", \"Health Expenditure (% of GDP)\"], rotation=0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "lasting-rainbow",
   "metadata": {},
   "outputs": [],
   "source": [
    "df_corr_round = food_supply.corr()[[\"Obesity\", \"Diabetes Prevalence\", \"Cardiovascular Death Rate\", \"Life Expectancy\", \"Health Expenditure\" ]].T[foods].T.round(2)\n",
    "fig = ff.create_annotated_heatmap(\n",
    "            z=df_corr_round.to_numpy(),\n",
    "            x=df_corr_round.columns.tolist(),\n",
    "            y=df_corr_round.index.tolist(),\n",
    "            zmax=1, zmin=-1,\n",
    "            showscale=True,\n",
    "            hoverongaps=True,\n",
    "            ygap=3\n",
    "            )\n",
    "\n",
    "fig.update_layout(yaxis_tickangle=-45, yaxis=dict(showgrid=False), xaxis=dict(showgrid=False))\n",
    "# add title\n",
    "fig.update_layout(title_text='<i><b>Correlation of Food Consumption and Health</b></i>',width=600, height=800)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "revolutionary-optics",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "level-brake",
   "metadata": {},
   "outputs": [],
   "source": [
    "food_supply.columns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "traditional-upset",
   "metadata": {},
   "outputs": [],
   "source": [
    "#health_cor = food_supply[[\"Obesity\", \"life_expectancy\", \"cardiovasc_death_rate\", \"gdp_per_capita\", \"human_development_index\", \"median_age\", \"population_density\"]].corr()[[\"Obesity\", \"life_expectancy\", \"cardiovasc_death_rate\"]].T\n",
    "#health_cor\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "apparent-pricing",
   "metadata": {},
   "outputs": [],
   "source": [
    "import plotly.graph_objs as go\n",
    "import statsmodels.api as sm\n",
    "\n",
    "df = food_supply.copy()\n",
    "col_name = str(\"Fruits - Excluding Wine\") + \"(above Average)\"\n",
    "df[col_name] = (df[\"Fruits - Excluding Wine\"] > df[\"Fruits - Excluding Wine\"].mean())#.astype(int)\n",
    "\n",
    "fig = px.scatter(df, x=\"Life Expectancy\", y =\"Fruits - Excluding Wine\", size=df[\"GDP per Capita\"], color=col_name,hover_name=df.index, log_x=False,marginal_x = \"box\",marginal_y = \"box\", template=\"simple_white\", color_discrete_sequence=[\"#0d0887\", \"#9c179e\"])\n",
    "\n",
    "# linear regression\n",
    "regline = sm.OLS(df[\"Fruits - Excluding Wine\"],sm.add_constant(df[\"Life Expectancy\"])).fit().fittedvalues\n",
    "\n",
    "# add linear regression line for whole sample\n",
    "fig.add_traces(go.Scatter(x=df[\"Life Expectancy\"], y=regline,\n",
    "                          mode = 'lines',\n",
    "                          marker_color='#fb9f3a',\n",
    "                          name='OLS Trendline')\n",
    "                          )\n",
    "\n",
    "fig.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "manual-memory",
   "metadata": {},
   "outputs": [],
   "source": [
    "df = food_supply.copy()\n",
    "col_name = str(\"Fruits - Excluding Wine\") + \": above Average\"\n",
    "df[col_name] = (df[\"Fruits - Excluding Wine\"] > df[\"Fruits - Excluding Wine\"].mean())#.astype(int)\n",
    "\n",
    "    \n",
    "size = df[\"Cardiovascular Death Rate\"]\n",
    "    \n",
    "fig = px.scatter(df, x=\"Life Expectancy\", y =\"Fruits - Excluding Wine\", size=size, color=col_name,hover_name=df.index, log_x=False, trendline = \"ols\",  trendline_color_override=\"#bd3786\",marginal_x = \"box\",marginal_y = \"box\", template=\"simple_white\", color_discrete_sequence=px.colors.qualitative.G10)\n",
    "fig.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "honey-distributor",
   "metadata": {},
   "outputs": [],
   "source": [
    "scatter_plot(food_supply , \"Life Expectancy\", \"Fruits - Excluding Wine\", \"Cardiovascular Death Rate\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "adverse-shareware",
   "metadata": {},
   "source": [
    "# Part 4: Correlation of the food habits and Covid-19 data about the country"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "innocent-terrain",
   "metadata": {},
   "source": [
    "This part investigates if there are any correlations between a countries eating habits and the Covid-19 data about the country. This data includes the following variables:\n",
    "* relative Cases\n",
    "* relative Deaths"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "capital-tennessee",
   "metadata": {},
   "outputs": [],
   "source": [
    "health_food_cor = food_supply.corr()[[\"total_cases_per_million\", \"total_deaths_per_million\"]].T[foods]\n",
    "fig = plt.figure(figsize=(17,5))\n",
    "sns.heatmap(health_food_cor.round(2), annot=True, cmap=\"plasma\", linewidths=0.2, vmin=-1, vmax=1).set_yticklabels([\"total_cases_per_million\", \"total_deaths_per_million\"], rotation=0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "strong-reverse",
   "metadata": {},
   "outputs": [],
   "source": [
    "#health_cor = food_supply[[\"total_cases_per_million\", \"total_deaths_per_million\", \"Obesity\", \"life_expectancy\", \"cardiovasc_death_rate\", \"gdp_per_capita\", \"human_development_index\", \"median_age\", \"population_density\"]].corr()[[\"total_cases_per_million\", \"total_deaths_per_million\"]].T\n",
    "#health_cor"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "hindu-religious",
   "metadata": {},
   "outputs": [],
   "source": [
    "scatter_plot(food_supply , \"total_cases_per_million\", \"Alcoholic Beverages\", \"total_deaths_per_million\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "growing-limit",
   "metadata": {},
   "source": [
    "## Evtl.: Part 4.0: Covid - general timelines per chosen country"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "expensive-transition",
   "metadata": {},
   "source": [
    "# Introducing health variables"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "minor-madonna",
   "metadata": {},
   "outputs": [],
   "source": [
    "health = food_supply[[\"Country\",\"Obesity\", \"Diabetes Prevalence\", \"Cardiovascular Death Rate\", \"Life Expectancy\", \"Health Expenditure\" ]]\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "civil-selling",
   "metadata": {},
   "outputs": [],
   "source": [
    "health = food_supply[[\"Country\",\"Obesity\", \"Diabetes Prevalence\", \"Cardiovascular Death Rate\", \"Life Expectancy\", \"Health Expenditure\" ]]\n",
    "\n",
    "\n",
    "\n",
    "fig = go.Figure()\n",
    "fig.add_trace(go.Bar(\n",
    "    x=health[\"Country\"],\n",
    "    y=health[\"Obesity\"],\n",
    "    name=\"Obesity\",\n",
    "    marker_color='#0d0887'\n",
    "))\n",
    "fig.add_trace(go.Bar(\n",
    "    x=health[\"Country\"],\n",
    "    y=health[\"Diabetes Prevalence\"],\n",
    "    name=\"Diabetes Prevalence\",\n",
    "    marker_color='#7201a8'\n",
    "))\n",
    "\n",
    "fig.add_trace(go.Bar(\n",
    "    x=health[\"Country\"],\n",
    "    y=health[\"Cardiovascular Death Rate\"],\n",
    "    name=\"Cardiovascular Death Rate\",\n",
    "    marker_color='#bd3786'\n",
    "))\n",
    "\n",
    "fig.add_trace(go.Bar(\n",
    "    x=health[\"Country\"],\n",
    "    y=health[\"Life Expectancy\"],\n",
    "    name=\"Life Expectancy\",\n",
    "    marker_color='#ed7953'\n",
    "))\n",
    "\n",
    "fig.add_trace(go.Bar(\n",
    "    x=health[\"Country\"],\n",
    "    y=health[\"Health Expenditure\"],\n",
    "    name=\"Health Expenditure (% of GDP)\",\n",
    "    marker_color='#fdca26'\n",
    "))\n",
    "# Here we modify the tickangle of the xaxis, resulting in rotated labels.\n",
    "fig.update_layout(barmode='group', xaxis_tickangle=-45)\n",
    "fig.update_layout(plot_bgcolor='white')\n",
    "fig.update_yaxes(showline=True, linewidth=2, linecolor='black', gridcolor='grey')\n",
    "fig.update_xaxes(showline=True, linewidth=2, linecolor='black')\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "classical-forest",
   "metadata": {},
   "outputs": [],
   "source": [
    "health = food_supply[[\"Country\",\"Obesity\", \"Diabetes Prevalence\", \"Cardiovascular Death Rate\", \"Life Expectancy\", \"Health Expenditure\" ]]\n",
    "\n",
    "\n",
    "\n",
    "fig = go.Figure()\n",
    "fig.add_trace(go.Bar(\n",
    "    x=health[\"Country\"],\n",
    "    y=np.log(health[\"Obesity\"]),\n",
    "    name=\"Obesity\",\n",
    "    marker_color='#0d0887'\n",
    "))\n",
    "fig.add_trace(go.Bar(\n",
    "    x=health[\"Country\"],\n",
    "    y=np.log(health[\"Diabetes Prevalence\"]),\n",
    "    name=\"Diabetes Prevalence\",\n",
    "    marker_color='#7201a8'\n",
    "))\n",
    "\n",
    "fig.add_trace(go.Bar(\n",
    "    x=health[\"Country\"],\n",
    "    y=np.log(health[\"Cardiovascular Death Rate\"]),\n",
    "    name=\"Cardiovascular Death Rate\",\n",
    "    marker_color='#bd3786'\n",
    "))\n",
    "\n",
    "fig.add_trace(go.Bar(\n",
    "    x=health[\"Country\"],\n",
    "    y=np.log(health[\"Life Expectancy\"]),\n",
    "    name=\"Life Expectancy\",\n",
    "    marker_color='#ed7953'\n",
    "))\n",
    "\n",
    "fig.add_trace(go.Bar(\n",
    "    x=health[\"Country\"],\n",
    "    y=np.log(health[\"Health Expenditure\"]),\n",
    "    name=\"Health Expenditure (% of GDP)\",\n",
    "    marker_color='#fdca26'\n",
    "))\n",
    "# Here we modify the tickangle of the xaxis, resulting in rotated labels.\n",
    "fig.update_layout(barmode='group', xaxis_tickangle=-45)\n",
    "fig.update_layout(plot_bgcolor='white')\n",
    "fig.update_yaxes(title_text=\"log\")\n",
    "fig.update_yaxes(showline=True, linewidth=2, linecolor='black', gridcolor='grey')\n",
    "fig.update_xaxes(showline=True, linewidth=2, linecolor='black')\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "aggregate-adelaide",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "tender-picking",
   "metadata": {},
   "outputs": [],
   "source": [
    "print(\"Hey\",  \"\\<b> Hey \\</b>\" )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "apparent-lending",
   "metadata": {},
   "outputs": [],
   "source": [
    "print('\\033[1m{:10s}\\033[0m'.format('Hey'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "designing-royal",
   "metadata": {},
   "outputs": [],
   "source": [
    "BOLD = '\\033[1m'\n",
    "END = '\\033[0m'\n",
    "print('{}{}{}'.format(BOLD, \"Hey\", END))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "desperate-smell",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "younger-nickname",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "blocked-chambers",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "distant-madrid",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "little-statistics",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "united-building",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "passive-income",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "final-draft",
   "metadata": {},
   "outputs": [],
   "source": [
    "food = [\"Alcoholic Beverages\", \"Animal fats\", \"Cereals - Excluding Beer\", \"Eggs\", \n",
    "                \"Fish, Seafood\", \"Fruits - Excluding Wine\", \"Meat\", \"Milk - Excluding Butter\",\n",
    "                \"Offals\", \"Oilcrops\", \"Pulses\", \"Spices\", \"Starchy Roots\",\"Stimulants\", \n",
    "                \"Sugar & Sweeteners\", \"Treenuts\", \"Vegetable Oils\",\n",
    "                \"Vegetables\" ]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "enormous-uruguay",
   "metadata": {},
   "outputs": [],
   "source": [
    "food.reverse()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "assumed-collection",
   "metadata": {},
   "outputs": [],
   "source": [
    "print(food)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "intense-estimate",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "floppy-discretion",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "hollywood-mounting",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "pursuant-patient",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "cooked-economy",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "hollywood-fraud",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "tired-panama",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "electric-defense",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "professional-penetration",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "stuck-spoke",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "neural-weekly",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "floppy-blond",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
